import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class TestMulticastSocketRecv {

	public static void main(String[] args) {
		try {
			InetAddress group = InetAddress.getByName("228.5.6.7");
			MulticastSocket socket = new MulticastSocket(39875);
			socket.joinGroup(group);
			DatagramPacket packet = new DatagramPacket(new byte[65535], 65535);
			while (true) {
				socket.receive(packet);
				System.out.println("recv:" + new String(packet.getData(), 0, packet.getLength()));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
